package com.zy.springboot.config;

import com.zy.springboot.interceptor.TimeInterceptor;
import com.zy.springboot.service.UserService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author zhaoyi
 * @date 2021/9/22 14:43
 */
@Configuration
public class WebConfigurer implements WebMvcConfigurer {


    //Interceptor 自动注入Service 需要这样处理
    /*@Bean
    public TimeInterceptor getTimeInterceptor(){
        return new TimeInterceptor();
    }*/


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        System.out.println("注册拦截器 ");
        registry.addInterceptor(new TimeInterceptor()).addPathPatterns("/**");
       /* registry.addInterceptor(getTimeInterceptor())
                .addPathPatterns("/**");*/

    }





}
